package com.xdx.doall.griddialog;

import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    SelectInsurDialog selectInsurDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        Button btn = findViewById(R.id.btn);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String[] number = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "", "0", ""};
                String[] letter = {"QZ", "ABC", "DEF", "GHI", "JKL", "MNO", "PRS", "TUK", "WXY", "", "", ""};
                List<InsurEntity> list = new ArrayList<InsurEntity>();
                for (int i = 0; i < number.length; i++) {
                    InsurEntity insurEntity = new InsurEntity(number[i], false);
                    list.add(insurEntity);
                }
//                InsurEntity insurEntity = new InsurEntity("太平洋保险",false);
//
//                InsurEntity insurBean1 = new InsurEntity("中国人保保险",false);
//                list.add(insurBean1);
//                InsurEntity insurBean2 = new InsurEntity("平安保险",false);
//                list.add(insurBean2);
//                InsurEntity insurBean3 = new InsurEntity("中华保险",false);
//                list.add(insurBean3);

                selectInsurDialog = new SelectInsurDialog(MainActivity.this, R.style.mall_Dialog);
                selectInsurDialog.setList(list);
                selectInsurDialog.setCanceledOnTouchOutside(true);
                selectInsurDialog.setDialogCallback(new SelectInsurDialog.DialogCallback() {
                    @Override
                    public void onClickRadioButton(String name) {
                        Toast.makeText(MainActivity.this, "你选择的是：" + name, Toast.LENGTH_SHORT).show();
                        selectInsurDialog.dismiss();

                    }
                });

                selectInsurDialog.show();
            }
        });


    }

    private void initView() {
        Typeface typeface = Typeface.createFromAsset(getAssets(), "iconfont.ttf");
        TextView tv1 = (TextView) findViewById(R.id.tv1);
        TextView tv2 = (TextView) findViewById(R.id.tv2);
        TextView tv3 = (TextView) findViewById(R.id.tv3);
        TextView tv4 = (TextView) findViewById(R.id.tv4);
        // 为TextView设置字体文件
        tv1.setTypeface(typeface);
        tv2.setTypeface(typeface);
        tv3.setTypeface(typeface);
        tv4.setTypeface(typeface);

    }
}
